package com.zxy.ziems.server.sync.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.baomidou.mybatisplus.annotation.IEnum;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Objects;

/**
 * 同步类型
 */
@AllArgsConstructor
@Getter
public enum SyncMetaType implements IEnum<String> {
    SYNC_POWER("SYNC_POWER", "同步能源"),
    DEVICE_MEASURE_DATA_DAY("device_measure_data_day", "设备测量数据天统计"),
    DEVICE_MEASURE_DATA_INCREMENT_HOUR("device_measure_data_increment_hour", "设备测量数据小时统计"),
    ENERGY_FLOW_DATA_DAY_KEY("energy_flow_data_day_key", "能流图天数据"),
    ENERGY_FLOW_DATA_MONTH_KEY("energy_flow_data_month_key", "能流图月数据"),
    SYNC_EMS_CIM_DAY_DATA("sync_ems_cim_day_data", "同步数据到cim"),
    ;

    /**
     * 状态值
     */
    @EnumValue
    @JsonValue
    private final String code;
    /**
     * 状态名
     */
    private final String message;


    @Override
    public String getValue() {
        return code;
    }

    @JsonCreator
    public static SyncMetaType getByCode(Integer status) {
        for (SyncMetaType value : SyncMetaType.values()) {
            if (Objects.equals(status, value.getCode())) {
                return value;
            }
        }
        return null;
    }
}
